<!-- 头部导航栏 -->
<template>
  <el-row>
    <div class="container">
      <transition
        appear
        name="animate__animated animate__bounce"
        enter-active-class="animate__fadeInDown"
        leave-active-class="animate__fadeOutDown"
      >
        <div class="nav">
          <el-col :offset="3" :xs="18" :sm="18" :xl="18">
            <div class="logo">
              <img src="../assets/logo.png" alt="Logo" />
              周张恒的博客
            </div>
          </el-col>
          <el-col :xs="3" :xl="3" :sm="3">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link">
                <van-icon name="wap-nav" />
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="/login">登录</el-dropdown-item>
                <el-dropdown-item command="/Published"
                  >发布文章</el-dropdown-item
                >
                <el-dropdown-item>修改信息</el-dropdown-item>
                <el-dropdown-item divided command="exit">退出</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-col>
        </div>
      </transition>
    </div>
  </el-row>
</template>

<script>
import { removeItem } from "../utils/storage.js";
export default {
  name: "myNav",
  data() {
    return {};
  },
  methods: {
    handleCommand(path) {
      if (path === "exit") {
        this.$store.commit("DELETE_USER");
        removeItem("user");
      } else this.$router.push(path);
    },
  },
};
</script>


<style lang="less" scoped>
.container {
  width: 100%;
  height: 80px;

  position: relative;
}
.nav {
  width: 100%;
  height: 80px;
  box-sizing: border-box;
  box-shadow: 0 1px 10px 0 #ccc;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: white;
  z-index: 99;
  .logo {
    font-size: 22px;
    display: flex;
    align-items: center;
    margin-left: -50px;
    img {
      height: 50px;
      width: 50px;
      margin-right: 8px;
    }
  }
  .van-icon {
    font-size: 30px;
  }
  .el-dropdown {
    text-align: center;
  }
}
</style>